package com.parachutes.aspinterfaceapi.domain;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;

/**
 * 接口表
 * @TableName bus_interface
 */
@TableName(value ="bus_interface")
@Data
public class BusInterface implements Serializable {
    /**
     * 接口ID，主键，自增
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 用户ID，外键，关联到sys_user表的id字段
     */
    private Integer userId;

    /**
     * 接口唯一标识，不能为空
     */
    private String interfaceKey;

    /**
     * 接口描述，默认为NULL
     */
    @TableField(value ="`desc`")
    private String desc;

    /**
     * 计费规则，使用JSON格式存储（如：次数，流量，字数等）
     */
    private String billingRules;

    /**
     * 价格，保留两位小数
     */
    private BigDecimal price;

    /**
     * 请求方式（GET, POST等），不能为空
     */
    private String method;

    /**
     * 接口URL，不能为空
     */
    private String url;

    /**
     * 加密类型（如：AES, None），默认为NULL
     */
    private String encryptionType;

    /**
     * 接口签名，默认为NULL
     */
    private String sign;

    /**
     * 记录创建时间，默认为当前时间
     */
    private Date createdAt;

    /**
     * 创建人ID，不能为空
     */
    private Integer createdBy;

    /**
     * 记录更新时间，自动更新时间戳
     */
    private Date updatedAt;

    /**
     * 更新人ID，不能为空
     */
    private Integer updatedBy;

    /**
     * 逻辑删除字段（0 = 未删除，1 = 已删除）
     */
    @TableLogic
    private Integer isDeleted;


    /**
     * 平均响应时间/ms
     */
    private String avgResponseTime;


    /**
     * 接口名称
     */
    private String name;


    /**
     * 状态
     */
    private Integer status;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        BusInterface other = (BusInterface) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
            && (this.getInterfaceKey() == null ? other.getInterfaceKey() == null : this.getInterfaceKey().equals(other.getInterfaceKey()))
            && (this.getDesc() == null ? other.getDesc() == null : this.getDesc().equals(other.getDesc()))
            && (this.getBillingRules() == null ? other.getBillingRules() == null : this.getBillingRules().equals(other.getBillingRules()))
            && (this.getPrice() == null ? other.getPrice() == null : this.getPrice().equals(other.getPrice()))
            && (this.getMethod() == null ? other.getMethod() == null : this.getMethod().equals(other.getMethod()))
            && (this.getUrl() == null ? other.getUrl() == null : this.getUrl().equals(other.getUrl()))
            && (this.getEncryptionType() == null ? other.getEncryptionType() == null : this.getEncryptionType().equals(other.getEncryptionType()))
            && (this.getSign() == null ? other.getSign() == null : this.getSign().equals(other.getSign()))
            && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
            && (this.getCreatedBy() == null ? other.getCreatedBy() == null : this.getCreatedBy().equals(other.getCreatedBy()))
            && (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()))
            && (this.getUpdatedBy() == null ? other.getUpdatedBy() == null : this.getUpdatedBy().equals(other.getUpdatedBy()))
            && (this.getIsDeleted() == null ? other.getIsDeleted() == null : this.getIsDeleted().equals(other.getIsDeleted()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
        result = prime * result + ((getInterfaceKey() == null) ? 0 : getInterfaceKey().hashCode());
        result = prime * result + ((getDesc() == null) ? 0 : getDesc().hashCode());
        result = prime * result + ((getBillingRules() == null) ? 0 : getBillingRules().hashCode());
        result = prime * result + ((getPrice() == null) ? 0 : getPrice().hashCode());
        result = prime * result + ((getMethod() == null) ? 0 : getMethod().hashCode());
        result = prime * result + ((getUrl() == null) ? 0 : getUrl().hashCode());
        result = prime * result + ((getEncryptionType() == null) ? 0 : getEncryptionType().hashCode());
        result = prime * result + ((getSign() == null) ? 0 : getSign().hashCode());
        result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
        result = prime * result + ((getCreatedBy() == null) ? 0 : getCreatedBy().hashCode());
        result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
        result = prime * result + ((getUpdatedBy() == null) ? 0 : getUpdatedBy().hashCode());
        result = prime * result + ((getIsDeleted() == null) ? 0 : getIsDeleted().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", userId=").append(userId);
        sb.append(", interfaceKey=").append(interfaceKey);
        sb.append(", desc=").append(desc);
        sb.append(", billingRules=").append(billingRules);
        sb.append(", price=").append(price);
        sb.append(", method=").append(method);
        sb.append(", url=").append(url);
        sb.append(", encryptionType=").append(encryptionType);
        sb.append(", sign=").append(sign);
        sb.append(", createdAt=").append(createdAt);
        sb.append(", createdBy=").append(createdBy);
        sb.append(", updatedAt=").append(updatedAt);
        sb.append(", updatedBy=").append(updatedBy);
        sb.append(", isDeleted=").append(isDeleted);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}